$package('YiYa.serCompany');
YiYa.serCompany = function(){
	var _box = null;
	var _this = {
		config:{
			event:{
				edit:function(){
					var selected = _box.utils.getCheckedRows();
					var record = selected[0];
					if(record.city!=null){
						var url = '../district/loadDistrictList.do?parentCode='+record.city.code;
						$('#cc2').combobox('reload', url);
					}
					_box.handler.edit();
				}
			},
			dataGrid:{
				title:'维修公司列表',
				url:'dataList.do',
				columns:[[
				          {field:'id',checkbox:true},
				          {field:'name',title:'公司名称',width:150},
				          {field:'linkman',title:'联系人',width:80},
				          {field:'phoneNumber',title:'公司电话',width:100},
				          {field:'mobileNumber',title:'手机号码',width:100},
				          {field:'city_code',title:'市',width:120,
				        	  formatter:function(value,row,index){
				        		  return new Object(row["city"]).name;
						  }},
						  {field:'county_code',title:'县(县级市、区)',width:120,
				        	  formatter:function(value,row,index){
				        		  return new Object(row["county"]).name;
						  }},
				          {field:'address',title:'地址',width:150}
				          ]],
				          toolbar:[
				                   {id:'btnadd',text:'添加',btnType:'add'},
				                   {id:'btnedit',text:'编辑',btnType:'edit'},
				                   {id:'btndelete',text:'删除',btnType:'remove'},
				                   {id:'btnview',text:'查看',btnType:'view'}
				                   ]
			}
		},
		init:function(){
			$('#cc1').combobox({
			    onChange:function(newValue,oldValue){
			    	$("#cc2").combobox('clear');
			    }
			});
			_box = new YDataGrid(_this.config);
			_box.init();
		}
	}
	return _this;
}();

$(function(){
	YiYa.serCompany.init();
});


